package com.hmall.search.config;

import com.hmall.search.pojo.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;



@Configuration
public class QueueConfigLoad {
    @Bean
    public Queue createQueue(){
        return new Queue(MqConstants.HOTEL_INSERT_QUEUE);
    }
    @Bean
    public Queue deleteQueue(){
        return new Queue(MqConstants.HOTEL_DELETE_QUEUE);
    }
    @Bean
    public TopicExchange getExchange(){
        return new TopicExchange(MqConstants.HOTEL_EXCHANGE,true,false);
    }
    @Bean
    public Binding create(){
        return BindingBuilder.bind(createQueue()).to(getExchange()).with(MqConstants.HOTEL_INSERT_KEY);
    }
    @Bean
    public Binding delete(){
        return BindingBuilder.bind(deleteQueue()).to(getExchange()).with(MqConstants.HOTEL_DELETE_KEY);
    }
}
